import jdk.internal.org.objectweb.asm.tree.MultiANewArrayInsnNode;

import java.util.Random;
import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: xiaotutu
 * Date: 2023-08-08
 * Time: 15:03
 */
public class Test {
    public static void main(String[] args) {
        //求两个正整数的最大公约数
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入：");
        int a = sc.nextInt();
        int b = sc.nextInt();
        int m = 1;
        while(true) {
            m = a % b;
            if(m != 0) {
                a = b;
                b = m;
            }else {
                System.out.println(b);
                break;
            }

        }
    }
    public static void main8(String[] args) {
        //求两个正整数的最大公约数
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入：");
        int a = sc.nextInt();
        int b = sc.nextInt();
        int m = (a < b ? a : b);

        while(true) {
            if(a%m ==0 && b%m ==0) {
                break;
            }
            m--;
        }
        System.out.println(m);
    }
    public static void main7(String[] args) {
        //输出乘法口诀表
        for (int i = 1; i <= 9; i++) {
            for (int j = 1; j <= i; j++) {
                System.out.print(i +"*" + j + "="+ i*j+" ");
            }
            System.out.println();
        }
    }
    public static void main6(String[] args) {
        //输出 1000 - 2000 之间所有的闰年
        for (int year = 1000; year <= 2000 ; year++) {
            if(year % 100 == 0) {
                if(year % 400 == 0) {
                    System.out.print(year + " ");
                }
            }else {
                if(year % 4== 0) {
                    System.out.print(year + " ");
                }
            }
        }
    }
    public static void main5(String[] args) {
        //打印 1 - 100 之间所有的素数
        int i = 1;
        for (; i <= 100 ; i++) {
            int j = 2;
            for (; j <= Math.sqrt(i); j++) {
                if(i % j ==0) {
                    break;
                }
            }
            if(j > Math.sqrt(i)) {
                System.out.print(i+" ");
            }
        }
    }
    public static void main4(String[] args) {
        //判定一个数字是否是素数
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入：");
        while(sc.hasNextInt()) {

            int n = sc.nextInt();
            int i = 0;
            for (i = 2; i <= Math.sqrt(n) ; i++) {
                if(n % i == 0) {
                    System.out.println("不是素数！");
                    break;
                }
            }
            if(i > Math.sqrt(n)) {
                System.out.println("是素数");
                break;
            }
        }
    }
    public static void main3(String[] args) {
        //猜数字游戏
        Scanner sc = new Scanner(System.in);
        Random random = new Random();
        int randNum = random.nextInt(100)+1;
        System.out.println("作弊" + randNum);
        while(true) {
            System.out.print("请输入:");
            int n = sc.nextInt();
            if(n > randNum) {
                System.out.println("猜大了");
            }else if(n == randNum) {
                System.out.println("恭喜你，猜对了!");
                break;
            }else {
                System.out.println("猜小了");
            }
        }
    }
    public static void main2(String[] args) {
        Scanner sc = new Scanner(System.in);
        while(sc.hasNextInt()) {
            int a = sc.nextInt();
            System.out.println(a);
        }
    }
    public static void main1(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.println("输入字符串：");
        String name = sc.nextLine();
        System.out.println(name);
        System.out.println("输入一个整数:");
        int a = sc.nextInt();
        System.out.println(a);
        //sc.nextLine();

    }
}
